<?php

namespace App\Api\Http\ApiControllers;

use App\Application\OrderService;
use Illuminate\Http\Request;

class PublisherOrderController extends Controller
{
    /**
     * @var OrderService
     */
    protected $order_service;

    public function __construct(OrderService $order_service)
    {
        $this->order_service = $order_service;
    }

    /**
     * 用户订单列表
     *
     * @param Request $request
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function index(Request $request)
    {
        $per_page = $request->get('per_page', 10);
        $data = $this->order_service->publisherOrders(access()->id(), $per_page);

        return response()->json($data);
    }

    /**
     * 订单详情
     *
     * @param $id
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function show($id)
    {
        $info = $this->order_service->showPublisherOrder($id, access()->id());

        return response()->json($info);
    }

}
